package at.horario.web.property.editor;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import at.horario.web.property.Property;


/**
 * Adapts data table columns to viewing properties
 *
 * @author igor.vaynberg
 */
public class PropertyColumnAdapter extends AbstractColumn implements IFilterableColumn {
    private final Property property;

    /**
     * Constructor
     *
     * @param property
     */
    public PropertyColumnAdapter(Property property) {
        super(property.getLabel(), property.getPath());
        this.property = property;
    }

    /**
     * {@inheritDoc}
     */
    public void populateItem(final Item item, String componentId, IModel rowModel) {
        item.add(property.getViewer(componentId, rowModel));
    }

    /**
     * {@inheritDoc}
     */
    public Component getFilter(String id, IModel model) {
        return property.getFilter(id, model);
    }


}
